package com.tbit.main.constant;

/**
 * Redis常量
 *
 * @author Leon
 * 2019年1月23日 下午3:49:52
 */
public class RedisConstant {

    /***************************用户相关***********************************/
    /**
     * 用户token
     */
    public static final String REDIS_ACCOUNT_USER = "USER_MAIN";
    /**
     * 用户对应的token列表
     */
    public static final String REDIS_ACCOUNT_USER_TOKEN_LIST = "USER.TOKEN.LIST.";

    /**
     * 设备前缀
     */
    public static final String REDIS_HASH_ID_HEAD = "uq";

    public static final String REDIS_TER_LAST_POS = "tLP";
    public static final String REDIS_TER_LAST_BATTERY = "tLB";
    public static final String REDIS_TER_ROUTE_KEY = "tRK";
    public static final String REDIS_TER_PKG_DT = "tLT";
    public static final String REDIS_TER_SYNC_TIME = "tST";
    public static final String REDIS_TER_SYNC_VALUE = "tSV";
    public static final String REDIS_TER_NEW_SOFTWAVE = "tNS";
    /**
     * 最后状态
     */
    public static final String REDIS_TER_LAST_STATUS = "tLS";
    /**
     * 换电记录缓存
     */
    public static final String REDIS_TER_BATTERY_CHANGE = "BATTERYCHANGE";
    /**
     * 挪车记录缓存
     */
    public static final String REDIS_TER_BIKE_MOVE = "BIKEMOVE";
    /**
     * 挪车记录缓存设备编号
     */
    public static final String REDIS_TER_BIKE_MOVE_USER_CODE = "BIKEMOVEUSERCODE";
    /**
     * 调度记录缓存
     */
    public static final String REDIS_TER_BIKE_DISPATCH = "BIKEDISPATCH";
    /**
     * 调度记录缓存设备编号
     */
    public static final String REDIS_TER_BIKE_DISPATCH_USER_CODE = "BIKEDISPATCHUSERCODE";
    /**
     * 换电记录二级hash
     */
    public static final String REDIS_TER_BIKE_BATTERY_CHANGE_MAP = "BATTERYCHANGEMAP";


    /**
     * 调度，挪车记录站点缓存
     */
    public static final String REDIS_TER_BIKE_DISPATCHANDMOVE = "BIKEDISPATCHANDMOVEPARKPOINT";
    /**
     * 指令摄像头拍照缓存 10秒，重复拍照
     */
    public static final String REDIS_TER_BIKE_PHOTO = "BIKEDISPHOTO";

    /**
     * 订单客户端小程序推送
     */
    public static final String REDIS_TER_BIKE_RIDELOG_PUSH = "CLIENTRIDELOGPUSH";

    /**
     * 换电记录订单缓存
     */
    public static final String REDIS_TER_BATTERY_CHANGE_RIDE = "BATTERYCHANGERIDE";
    /**
     * 换电记录订单二级hash
     */
    public static final String REDIS_TER_BIKE_BATTERY_CHANGE_RIDE_MAP = "BATTERYCHANGERIDEMAP";

    public static final String ORDERS_AFTER_LAST_DISPATCH_MACHINE = "orders.after.last.dispatch.machine:%s";

    /**
     * 调度记录订单缓存
     */
    public static final String REDIS_TER_DISPATCH_CHANGE_RIDE = "DISPATCHCHANGERIDE";

    /**
     * 挪车记录订单缓存
     */
    public static final String REDIS_TER_MOVE_CHANGE_RIDE = "MOVECHANGERIDE";
    /**
     * 调度记录订单二级hash
     */
    public static final String REDIS_TER_BIKE_DISPATCH_CHANGE_RIDE_MAP = "DISPATCHCHANGERIDEMAP";
    /**
     * 挪车记录订单二级hash
     */
    public static final String REDIS_TER_BIKE_MOVE_CHANGE_RIDE_MAP = "MOVECHANGERIDEMAP";
    /**
     * 调度记录距离二级hash
     */
    public static final String REDIS_TER_BIKE_DISPATCH_DISTANCE_CHANGE_MAP = "DISPATCHCHANGERIDEDISTANCE";
    /**
     * 挪车记录距离二级hash
     */
    public static final String REDIS_TER_BIKE_MOVE_DISTANCE_CHANGE_MAP = "MOVECHANGERIDEDISTANCE";
    /**
     * 资产预警
     */
    public static final String REDIS_KEY_MACHINE = "MACHINE";

    /**
     * 天气缓存
     */
    public static final String REDIS_WEATHER_NEW = "WEATHER.NEW";
    public static final String REDIS_WEATHER_NEW_DATE = "WEATHER.NEW.DATE";

    /**
     * 非法移动告警
     */
    public static final String REDIS_KEY_ILLEGALITY_MOVE = "ILLEGALITY";
    /**
     * 车辆倾倒告警
     */
    public static final String REDIS_KEY_ILLEGALITY_ROLL = "ROLLOVER";
    /**
     * 摄像头故障告警
     */
    public static final String REDIS_KEY_ILLEGALITY_SXTGZ = "SXTGZ";
    /**
     * 摄像头遮挡告警
     */
    public static final String REDIS_KEY_ILLEGALITY_SXTZD = "SXTZD";
    /**
     * 批量调度，运维人员正在调度的车辆
     */
    public static final String REDIS_BATCH_DISPATCH = "BATCHDISPATCH";
    /**
     * 批量调度，区域正在调度的车辆
     */
    public static final String REDIS_BATCH_DISPATCH_AREA = "BATCHDISPATCH.AREA";
    /**
     * 批量挪车
     */
    public static final String REDIS_BATCH_MOVE = "BATCHMOVE";
    /**
     * 批量挪车，区域正在挪车的车辆
     */
    public static final String REDIS_BATCH_MOVE_AREA = "BATCHMOVE.AREA";

    /**
     * GPS查车登陆
     */
    public static final String REDIS_GPS = "REDISGPS";

    /**
     * 运维人员轨迹记录
     */
    public static final String REDIS_KEY_ACCOUNTUSERID = "USERIDHISTORY";

    /**
     * 工单
     */
    public static final String REDIS_WORK_ORDER = "WORK.ORDER";
    /**
     * 工单阈值
     */
    public static final String REDIS_WORK_ACCOUNT = "WORK.NUMBER";
    /**
     * 工单推送
     */
    public static final String REDIS_WORK_PUSH = "WORK.PUSH";
    /**
     * 换电工单二级
     */
    public static final String REDIS_WORK_ORDER_HD = "WORK.HD";
    /**
     * 调度挪车工单缓存
     */
    public static final String REDIS_WORK_ORDER_NC = "WORK.NC";

    /**
     * 客户端订单推送
     */
    public static final String REDIS_CLIENT_RIDELOG_PUSH = "RIDELOG_PUSH";

    /**
     * 客户端订单推送，借车头盔锁状态
     */
    public static final String REDIS_CLIENT_RIDELOG_PUSH_HTML = "RIDELOG_PUSH_HTML";

    /**
     * 远程控制操作结果
     */
    public static final String terControl = "TER_CONTROL_";
    /**
     * 远程控制
     */
    public static final String terControlMsg = "TER_CONTROL_MSG_";


    /**
     * 未关电池锁缓存
     */
    public static final String REDIS_BATTERY_LOCK = "BATTERY_LOCK_";

    /**
     * 用户借车头盔锁状态
     */
    public static final String MACHINE_NO_HELMET = "helmet";
    /**
     * 运维还车头盔锁状态
     */
    public static final String MACHINE_NO_HELMET_MAIN = "helmet_main_";

    /**
     * 推送bms,设备：电池
     */
    public static final String PUSH_BMS_Machine = "PUSH_BMS_M_";
    /**
     * 推送bms,电池信息
     */
    public static final String PUSH_BMS_Battery = "PUSH_BMS_B_";
    /**
     * 推送bms,电池型号信息
     */
    public static final String PUSH_BMS_Model = "PUSH_BMS_BM_";

    /**
     * 远程拍照缓缓存，图片存储到ruleRidephotolog
     */
    public static final String PHOTO = "PHOTO_SN";

    /**
     * 短信验证码错误次数
     */
    public static final String SMS_MAIN = "SMS_MAIN_";
    /**
     * 短信验证码错误限制
     */
    public static final String SMS_MAIN_ERROR = "SMS_MAIN_ERROR";

    /**
     * 骑行中，通知
     */
    public static final String MACHINE_BORROW_SOC_ = "MACHINE_BORROW_";
    /**
     * 骑行中，客户端通知
     */
    public static final String MACHINE_BORROW_SOC_CLIENT = "MACHINE_BORROW_CLIENT";
    /**
     * 骑行中，管理平台通知
     */
    public static final String MACHINE_BORROW_SOC_MANAGER = "MACHINE_BORROW_MANAGER";
    /**
     * 骑行中，运维断电通知
     */
    public static final String MACHINE_BORROW_SOC_MAIN = "MACHINE_BORROW_MAIN";

    /**
     * 静止临停
     */
    public static final String MACHINE_PARK = "MACHINE_PARK";

    /**
     * 车辆占用map
     */
    public static final String REDIS_machineUnLockMap = "MACHINEUNLOCKMAP_";
    /**
     * 车辆取消占用map
     */
    public static final String REDIS_machineLockMap = "MACHINELOCKMAP_";

    public static final String operationalDataToMain = "OPERATIONALDATATOMAIN";

    /**
     * 调度申请记录
     */
    public static final String MACHINE_DISPATCH_APPLY_LOG = "MACHINE_DISPATCH_APPLY_LOG";
    /**
     * 账号到期时间
     */
    public static final String ACCOUNT_USER_EXPIRE_DATE = "accountUserExpireDate:";
    /**
     * 定时任务头盔丢失
     */
    public static final String QUARTZ_HELMET_DS = "QUARTZ_HELMET_DS";
    /**
     * pc账号最近登录时间
     */
    public static final String ACCOUNT_USER_PC_LOGIN_DATE = "accountUserPcLoginDate:";
    /**
     * pc账号免登录有效时间
     */
    public static final String ACCOUNT_USER_PC_FREE_LOGIN = "accountUserPcFreeLogin:";

    /**
     * 运维账号最近登录时间
     */
    public static final String ACCOUNT_USER_MAIN_LOGIN_DATE = "accountUserMainLoginDate:";
    /**
     * 运维账号免登录有效时间
     */
    public static final String ACCOUNT_USER_MAIN_FREE_LOGIN = "accountUserMainFreeLogin:";

    /**
     * 超时结束订单头盔丢失
     */
    public static final String QUARTZ_HELMET_DS_RIDELOG = "QUARTZ_HELMET_DS_RIDELOG";

    /**
     * 品牌配置缓存
     */
    public static final String BRANDREMOTECONFIG_KEY_PREFIX = "BRANDREMOTECONFIG#";
    /**
     * 系统配置缓存前缀
     */
    public static final String CONFIG_KEY_PREFIX = "CONFIG#";

    public static final String ACCOUNT_USER_LOCK_KEY = "main.%s%s.%s";


    public static final String BATCH_MOVE_MACHINE = "batch.move.machine";

    /**
     * 用量提醒redis key
     */
    public static final String USAGE_KEY = "donTRemindMeToday_";

    /**
     * 人脸校验key
     */
    public static final String FACE_CHECK = "face_check";

    /**
     * bms电池绑定的车辆
     */
    public static final String BMS_BATTERY_BOUND = "BMS_BATTERY_BOUND:";

    /**
     * 登录锁定时间key format
     */
    private static final String LOGIN_LOCK_TIME_FORMAT = "errorCode.%s.%s.lockTime";
    /**
     * 登录错误次数计数key format
     */
    private static final String LOGIN_LOCK_COUNT_FORMAT = "errorCode.%s.%s";
    /**
     * 自定义临时通电时长前缀
     */
    public static final String TEMP_POWER_KEY = "temp_power_key";
    /**
     * 推车缓存设备编号
     */
    public static final String REDIS_TER_BIKE_PUSH_MACHINE_USER_CODE = "BIKEPUSHMACHINEUSERCODE";






    /**
     * 获取锁定时间Key
     *
     * @param phone    手机号
     * @param clientIP ip
     * @return
     */
    public static String getLockTimeKey(String phone, String clientIP) {
        return String.format(LOGIN_LOCK_TIME_FORMAT, phone, clientIP);
    }

    /**
     * 获取错误次数计数key
     *
     * @param phone
     * @param clientIP
     * @return
     */
    public static String getLockCountKey(String phone, String clientIP) {
        return String.format(LOGIN_LOCK_COUNT_FORMAT, phone, clientIP);
    }
}
